import xhr from './xhr/'

/**
 * 对应后端涉及到用户认证的 API
 */
class SystemService {

	getLicense() {
		return xhr({ 
			url: 'license/read'
		})
	}

	saveConfig() {
		return xhr({ 
			url: '/sys_conf/xmsd/SaveConfig.php'
		})
	}

	changePwd(old_pwd,new_pwd) {
		return xhr({ 
    	url: '/user/change_password.php',
    	method: 'POST',
    	body: {old_pwd:old_pwd,new_pwd:new_pwd}
    })
	}

	sysUpload(file) {
		return xhr({ 
    	url: '/sys_conf/UploadImage.php',
			method: 'POST',
			body:file
    })
	}

	exportConf() {
		return xhr({ 
    	url: '/sys_conf/xmsd/ExportConfig.php'
    })
	}

	sysReset() {
		return xhr({ 
    	url: '/sys_conf/Reset.php'
    })
	}

	bkconfUpload(file) {
		return xhr({ 
    	url: '/sys_conf/xmsd/UploadConfig.php',
    	method: 'POST',
    	body: {file}
    })
	}
	
	command(cmd) {
		return xhr({ 
    	url: 'sysconf/command',
    	method: 'get',
    	body: {t:cmd}
    })
	}

	checkStart(cmd) {
		return xhr({ 
    	url: '/sys_conf/CheckStart.php'
    })
	}
/*********时间日期**************/
	getTime() {
		return xhr({ url: 'sysconf/get?t=5'})
	}

	setTime(systime) {
		return xhr({ 
			url: 'sysconf/update?t=5',
			method: 'POST',
			body: {
				'5':systime
			}
		})
	}
/********获取系统版本**********/
	getSysinfo() {
		return xhr({ url: 'stats/get?t=23|20|24|4'})
	}

	doBypass(bypass) {
		return xhr({
			url: '/sys_conf/bypass.php',
			method: 'POST',
			body: {oper:bypass.oper,group:bypass.group}
		})
	}
	/********集中管理***********/
	getSysPolice(params) {
		return xhr({
			url: 'sysconf/get?t=4'
		})
	}
	setSysPolice(params) {
		return xhr({
			url: 'sysconf/update?t=4',
			method: 'post',
			body: {
				4: params
			}
		})
	}
	/*********系统策略*********/
	getNetParams () {
		return xhr({
			url: 'sysconf/get?t=1|2|3'
		})
	}
	setNetParams (params) {
		return xhr({
			url: 'sysconf/update?t=1|2|3',
			method: 'post',
			body: params
		})
	}
	getNetMangage (params) {
		return xhr({
			url: 'sysconf/get',
			method: 'get',
			body: params
		})
	}
	addNetMangage (params) {
		return xhr({
			url: 'sysconf/add?t=6',
			method: 'post',
			body: params
		})
	}
	editNetMangage (params) {
		return xhr({
			url: 'sysconf/update?t=6',
			method: 'post',
			body: params
		})
	}
	delNetMangage (params) {
		return xhr({
			url: 'sysconf/del?t=6',
			method: 'post',
			body: params
		})
	}



	getNetDiagnose(params) {
		return xhr({
			url: '/sys_conf/net_test.php?oper='+params.oper,
			method: 'POST',
			body: {
				ip:params.ip,
				times:params.times,
				length:params.length,
				min_ttl:params.min_ttl,
				max_ttl:params.max_ttl
			},
			datatype:'String'
		})
	}
  
	getLine() {
		return xhr({
			url: 'utils/ethgroups',
			method: 'get'
		})
	}

}

// 实例化后再导出
export default new SystemService()